home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / Finder Progress Bar / Finder ProgressBar.h < prev    next >
Encoding:
Text File  |  1993-08-27  |  3.1 KB  |  57 lines  |  [TEXT/KAHL]

  1. /*****************************************************************************************************
  2. *                                                                                                    *
  3. * Finder ProgressBar.h - Copyright 1993 Chris Larson (cklarson@engr.ucdavis.edu) All rights reserved *
  4. *                                                                                                    *
  5. * This is the header file for a CDEF which mimics the progress bar used by the Finder. This file and *
  6. * compiled derivatives may be freely used within any freeware/shareware/postcardware/beerware/… as   *
  7. * long as you mention my name in your credits. Neither this source nor its compiled derivatives are  *
  8. * in the public domain and may not be use in any form in public domain software. Neither this source *
  9. * nor its compiled derivatives may be used in any form in a commercial product without the expressed,*
  10. * written consent of the author (me).                                                                *
  11. *                                                                                                    *
  12. * Version 1.0 -- Initial Release.                                                                    *
  13. *                                                                                                    *
  14. *****************************************************************************************************/
  15.  
  16. // Constants
  17.  
  18. #define kNoColorQD    0x4000    // If this bit in ROM85 is set, color QD is not available.
  19.  
  20. #define cGray        { 0x4444, 0x4444, 0x4444 }    // Color of bar itself.
  21. #define cBlue        { 0xCCCC, 0xCCCC, 0xFFFF }    // Color of space bar fills.
  22. #define cBlack        { 0x0000, 0x0000, 0x0000 }    // Frame color and color-mapping background.
  23. #define cWhite        { 0xFFFF, 0xFFFF, 0xFFFF }    // Color-mapping background.
  24.  
  25. // Inline Functions (NOTE: These routines are _not_ general. They work here only. Don't use them
  26. //                  elsewhere unless you understand thier limitations)
  27.  
  28. void MySetUpA4(void)
  29.     = { 
  30.         0x2F0C,                //  MOVE.L    A4,-(A7)        ; Push A4
  31.         0x2848                //    MOVEA.L    A0,A4            ; Make A4 point to the code resource
  32.       };
  33.  
  34. void MyRestoreA4(void)
  35.     = {
  36.         0x285F                //    MOVE.L    (A7)+,A4        ; Pop A4
  37.       };
  38.  
  39. #pragma parameter __D0 CalcBarBoundry (__A1, __A0)
  40. short CalcBarBoundry (Rect *theBox, ControlPtr theControl)
  41.     = {
  42.         0x3029, 0x0002,        //  MOVE.W    $0002(A1),D0    ; rect left edge to d0
  43.         0x3229, 0x0006,        //  MOVE.W    $0006(A1),D1    ; rect right edge to d1
  44.         0x9240,                //  SUB.W    D0,D1            ; rect width to d1
  45.         0x3428, 0x0016,        //  MOVE.W    $0016(A0),D2    ; control max to d2
  46.         0x9468, 0x0014,        //  SUB.W    $0014(A0),D2    ; control range to d2
  47.         0x6708,                //  BEQ.S    *+$000A            ; if range==0, exit to avoid divide by 0
  48.         0xC2E8, 0x0012,        //  MULU.W    $0012(A0),D1    ; width*value to d1 (32 bit product)
  49.         0x82C2,                //  DIVU.W    D2,D1            ; (width*value)/range to d1 (16 bit quotient)
  50.         0xD041                //  ADD.W    D1,D0            ; offset by left edge of rect
  51.       };
  52.  
  53. // Function Prototypes
  54.  
  55. pascal long main (short varCode, ControlHandle theControlHandle, short message, long param);
  56. void DrawProgressBar (ControlHandle theControlHandle);
  57.